`
duoerbasilu
  • 浏览: 1483259 次
文章分类
社区版块
存档分类
最新评论

Net/HTTP debug tips

 
阅读更多

set debug output

http = Net::HTTP.new("www.something.com", 80)
http.set_debug_output($stdout)

这样就可以在post的时候显示传输的内容,便于调试。

使用nc监视http请求数据

浏览器请求数据可以通过firebug等工具查看,但是有时候需要自己的程序去请求其他应用,这样调试起来很不方便。
通过netcat可以监听一个端口,并且随时回显请求的数据的最原始状态。

终端1:

 nc -v -l localhost 12345

返回:

Connection from 0.0.0.0 port 12345 [tcp/*] accepted
PUT / HTTP/1.1
User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: localhost:12345
Accept: */*
Content-Length: 5
Content-Type: application/x-www-form-urlencoded

{a:1}

终端2:

curl -XPUT http://localhost:12345 -d '{a:1}'

net/http set_form_data

Ruby自带的net/http库,的set_form_data方法在传输之前会进行encode_www_form编码,而普通的post方法是不会的:

def set_form_data(params, sep = '&')
  query = URI.encode_www_form(params)
  query.gsub!(/&/, sep) if sep != '&'
  self.body = query
  self.content_type = 'application/x-www-form-urlencoded'
end



http://rubylution.herokuapp.com/topics/20

分享到:
评论

相关推荐

    Android Debug Tips.ppt

    android入门学习的教程,主要讲调试debug相关的内容,非常的好,适合新手看看

    Android代码-debug_view_kotlin

    推荐项目kotlin_tips,用Kotlin去提高生产力:汇总Kotlin相对于Java的优势,以及怎么用Kotlin去简洁、务实、高效、安全开发的Tips 推荐项目easy_mock_api,给客户端同学的模拟json接口的小工具 推荐项目CompatWebView...

    Android代码-kotlin_tips

    推荐:Kotlin的实践项目debug_view_kotlin,用Kotlin实现的Android浮层调试控制台,实时的显示内存、FPS、App启动时间、Activity启动时间、文字Log 推荐:数据预加载项目and-load-aot,通过提前加载数据来提高页面...

    TMAX debug

    synopsys TMAX: Tips For Simulation Debug, ATPG Pattern Validation

    网站抓取精灵

    <script src="http://discuz.gtimg.cn/cloud/scripts/discuz_tips.js?v=1" type="text/javascript" charset="UTF-8"></script><script type="text/javascript">document.getElementById("debuginfo").innerHTML = ...

    三星9305收索

    [endif]--><style data-for="debug">#debug{display:none!important}</style><style index="index">#u1 a:link,#u1 a:visited{color:#666;text-decoration:none}#u1 a:hover,#u1 a:active{text-decoration:underline...

    Eclipse – 整合开发工具

    要訣和技巧(Tips and Tricks) 266 <br/>7.1編輯程式檔(Editing Source) 266 <br/>7.2搜尋(Searching) 271 <br/>7.3程式碼導覽和讀取(Code navigation and reading) 273 <br/>7.4 Java視圖(Java views) 277 <br/>7.5...

    liteIdex34.1

    * Source code navigation and information tips * Source code find usages * Source code refactoring and revert * Integrated [gocode](https://github.com/visualfc/gocode) clone of [nsf/gocode]...

    深入浅出mfc简体中文版

    * 讀者來函 / 1 * 第㆓版序 / 5 第㆒版序/ 7 目錄/ 13 第0章 你㆒定要知道(導讀) / 27 這本書適合誰/ 27 你需要什麼技術基礎/ 29 你需要什麼軟硬體環境/ 29 讓我們使用同㆒種語言/ 30 本書符號習慣/ 34 ...

    Django 1.1 Testing and Debugging.pdf

    Tips on asking questions that will get good answers 370 Opening a new ticket to report a problem 372 Summary 374 Chapter 11: When it's Time to Go Live: Moving to Production 375 Developing an ...

    ETS364 Programmers_Book_Rev6_READER+COMMENTS.pdf

    APU-12, SPU-100 & debug fundamentals Basics of Pattern based testing pattern based testing of a DUT Groupset accumulator Optimizing a test Introduction to Per Pin digital introduction of digital...

    UE(官方下载)

    This power tip provides an explanation as well as some tips to get the most out of temp files. Backup and Restore Settings One of the staples of UltraEdit (and UEStudio) is its highly configurable ...

    Writing Windows WDM design drivers

    This well-paced and informative guide offers numerous excellent tips, including how to design device drivers that fit your needs, and a good deal of material on how to test and debug driver code. ...

    Perl Debugged.pdf

    3.7 Tips for Reducing Complexity....................................................................................26 Chapter 4. Perl Pitfalls..........................................

    Programmers.Guide.to.Drupal.Principles.Practices.and.Pitfalls.2nd.Edition

    Learn programming tips and tools to help you perfect and debug your applications Table of Contents Chapter 1. Overview of Drupal Chapter 2. Drupal Programming Principles Chapter 3. Common Drupal ...

    WordPress Theme Design: A complete guide to creating professional WordPress themes

    * Debug and validate your theme using W3C's XHTML and CSS validation tools * Customize and tweak your theme's layout * Set up dynamic drop-down menus, AJAX/dynamic and interactive forms * Download and...

    Learn Angular The Collection

    Chapter 3:Using Angular Augury to Debug Your Code Chapter 4:Top Angular Plugins for Sublime Text Chapter 5:Boosting Your Workflow with Angular 5 Snippets and VS Code Chapter 6:Top 12 Productivity Tips...

    Flex 3 A Beginners Guide

    profile and debug your applications; and manage media assets. Designed for Easy Learning Key Skills & Concepts--Chapter-opening lists of specific skills covered in the chapter Ask the Experts--Q&...

    Java.EE.Development.with.Eclipse.2nd.Edition.178528534

    Develop, debug, test, and troubleshoot Java EE 7 applications rapidly with Eclipse About This Book Go beyond simply learning Java EE APIs and explore the complete workflow of developing enterprise ...

    [C#] Windows Runtime via C# (英文版)

    And you'll gain practical insights and tips for how to architect, design, optimize, and debug your apps. ☆ 出版信息:☆ [作者信息] Jeffrey Richter , Maarten van de Bospoort [出版机构] Microsoft ...

Global site tag (gtag.js) - Google Analytics