Read chunked HTTP in .Net - chunked-encoding

I'm trying to write a VB.net client that reads HTTP chunked data. The chunks contain additional information that I need to use.
I've already figured out that I can't use the HTTPWebResponse, since it hides the optional tags.
So, the way I understand it, I need to use a TCPClient, send the HTTP request through it, and then parse the response.
My question at this point is how do I create and send the HTTP request, especially as HTTPWebRequest is not serializable.
Any help, including an indication of a better way to do this, would be appreciated.

If you#re going to use TCPClient, then you're going to have to do the request by hand. Fortunately, HTTP is a reasonably easy to do. Just write the headers you need to send delimited by /n/r.
You'll probably want/need to read up on the HTTP spec.

Related

Should a Get-Ajax request change data on the server?

I read documents online. They say that
A GET-Ajax request is used for getting data from the server.
A POST-Ajax request is used for change data on the server.
But why is it?
A Get-Ajax request can change the data on the server TOO, right?
Why should only the POST-Ajax request change the data?
Is it because of a security reason or something? Please explain to me
GET and POST are different methods for web requests that provide different features/describe different intentions for programmers and APIs. You are correct that, technically speaking, if you want to do some other CRUD operation on the server when using a GET request, you can. Most would probably argue that this is not a good idea, in part for security/performance features that either method provides. Example: GET requests can be cached, POST cannot.
More on that here: https://www.w3schools.com/tags/ref_httpmethods.asp

How does chunked downloading work in http/2 (or better what is the equivalent?)

In chunked downloading, there are extensions on each chunk that can be leveraged when coming to a browser. the last chunk can also contain optional headers defining stuff like content-length if we streamed a big file through, we can provide that information at the very end in the form of a http header.
How does this work in http/2? Are there even extensions or headers in last piece. I see there is Data payload but there is no extensions nor optional headers AFAICT. I only see padding.
Maybe a better question is do browsers even
leverage the optional headers in the last chunk?
leverage extensions in each chunk?
Perhaps programs may care but if it is a progam, I believe in http/2, the server just defines the api better perhaps and uses a push mechanism after response+data has been sent maybe?
How would one send optional headers in this new http/2 world though if I was a server defining an api for clients?
I was trying to use wireshark to capture a download trace but chrome seems to use QUICK and I can't seem to decrypt the SSL with wireshark for this use case when I use firefox and drive.google.com to download a file(it stays encrypted while in the same trace, I actually saw some http2 traffic in TLS for some other service working just fine). Using the "(Pre)-Master-Secret log filename" seems to only work half the time and I am not quite sure why. I end up having to restart everything and re-run my cases.
Also, in the Server hello, h2 was the protocol selected but then no http2 packets appear when I filter to ip.addr=(server hello google ip) and tcp.port=443
thanks,
Dean
In chunked downloading, there are extensions on each chunk that can be leveraged when coming to a browser. the last chunk can also contain optional headers defining stuff like content-length if we streamed a big file through, we can provide that information at the very end in the form of a http header.
In theory (i.e. standard) you have the extensions and the possibility to add non-essential(!) headers at the end. In practice these feature are not used. I'm not aware of any chunk extensions which are defined which means that browsers simply ignore them. And the example trailer defining a content-length makes no sense because with chunked encoding any content-length header should be ignored. There might be some third party libraries which make use of trailers. But since support for trailers would need to be declared up-front by the client (using TE:trailers header) browsers don't use it.
If I understand HTTP/2 correctly chunk extensions are simply gone (nothing lost, they were never used). Trailers are still possible, i.e. you could add headers after all data are sent, see RFC7540: 8.1 HTTP Request/Response Exchange.

How do you change the HTTP verb for DalekJS tests?

The DalekJS documentation for the open() action says "You can forge GET, POST, PUT, DELETE and HEAD requests".
Can anyone tell me how to do this? I need to send POST, PUT & DELETE requests to the server for some tests.
per definition the Webdriver Spec & the underlying JSON-Wire protocol do not support manipulation the HEADERS of a request.
That seems like a limitation, but makes sense if you think about what the protocol is designed for. It is designed to "simulate" a "real" user. What a real user normally doesn't do, is changing the HEADERS of its request.
There are other tools if you want to test a REST interface, Dalek isn't (becauseof the underlying protocol) not designed to test such things.

BubbleWrap HTTP get request

I have an app that I am trying to pull data from a remote database. I have the url and the table columns and database name but i'm not sure how to call on that database with an http get. Below is my code:
def self.data
BubbleWrap::HTTP.get("url", {credentials: {username: '***', password: '***'}}) do |response|
p response.to_s
end
end
I know this request is working because it shows me data in the console.I can't find anywhere how to request information from a database attached that url. Any help would be greatly appreciated. I have been working with Ruby for a year now but new to RubyMotion.
Not sure to understand exactly your question, but you might want to take a look at this link and this one, explaining how to retrieve and handle data from a service.
Hope it helps.
This may be too elementary, but with an HTTP request you are not querying a database, you are requesting data from an HTTP server. It's the job of the server to look your request over, go to the database, retrieve the data, package it (often in JSON format), and ship it back. I believe that's what #railsdog was referring to in terms of marshaling.
Now, a couple of other comments:
"url" in your code should be an actual endpoint like https://my.server.org/api/some_endpoint.json. The payload containing credentials can be attached as a query string, however, you might want to consider POST and SSL, as I say in my next point.
You should never send credentials in clear text over HTTP. If you have to send sensitive information, use HTTPS (set up your server to respond to SSL-encrypted requests).
It's probably best to authenticate once on first request and get a token you can use on subsequent requests so as not to expose usernames and passwords unduly. Perhaps you can fill in a few blanks about what your server is (Rails, some public API, other) and it will make it easier to help.
You will need to accept the data from the server in some recognizable format. JSON is very well supported. BubbleWrap has a JSON parser to help turn the results into a hash. Alternate formats are XML (ick) or XML-RPC (ick, ick), or SOAP (ick, ick, ice).
If you're way ahead of me on this and it's too basic to be of use, I apologize.

Modifying HTTP request and responses with a Browser Helper Object

I want to modify HTTP requests headers using an Internet Explorer Browser Helper Object.
I basically need to change a few headers for every request, and then modify the response before it returns to the browser.
I tried using the OnNavigate2 events, but those don't even give you access to all of the headers.
I tried making an Asynchronous Pluggable Protocol, but then I don't really have access to the default HTTP implementation, and i can't override the default HTTP requests.
Do you have any idea how this is supposed to be done?
I prefer C#, but could use C++ if necessary.
It can be done with URL monikers.
There is an implementation of something like that by a guy called Igor Tandetik.
You can find links to the code in: microsoft.public.inetsdk.programming google group - just look for PassthruAPP.
(I would have posted a link but apparently new users are not allowed to do this)
It doesn't directly support modifying the response body though.
You will have to insert a hook into the IInternetProtocolImpl::Read method.
The easiest way to do it is to use an http proxy to intercept everything the way Fiddler does.
See this description of the Fiddler PowerToy (Part 1).
It seems that you can only modify CUSTOM headers by using the headers parameters of the BeforeNavigate2 event. Not all the headers are accessible. This is a way to try to minimize the potential of the BHOs to act as a Trojans. Use a HTTP proxy instead.

Resources