Setting User-Agent for http:send-request?

Wednesday, 31 October 2012 · 4 messages · last reply 1 Nov 2012
CG
Christian Grünin reply to Erol Akarsu, 1 Nov 2012, 00:2131 Oct 2012 23:25 #
This may work:
  <http:header name="User-Agent" value="blub"/>
The spec may give you some more hints [1]. Christian [1] http://www.expath.org/spec/http-client
Quoted text · Erol Akarsu · 23 lines
> I am trying to set User-Agent header attribute for an HTTP request with > following code snippet. > > > let $content := http:send-request(<http:request method='get' > status-only='false' User-Agent='Mozilla/5.0'/>, $url) > let $body := $content[2] > return $body > > But It is sending "Java/1.7.0_02" as User-Agent header attribute. This has > been taken from wireshark: > > GET / HTTP/1.1 > User-Agent: Java/1.7.0_02 > Host: istanbul.olx.com.tr > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 > Connection: keep-alive > > Do we have any way to set the user-agent attribute? > > Thanks > > Erol Akarsu
EA
Erol Akarsu1 Nov 2012 00:21 #
Hi, I am trying to set User-Agent header attribute for an HTTP request with following code snippet.
let $content := http:send-request(<http:request method='get'
status-only='false' User-Agent='Mozilla/5.0'/>, $url)
 let $body := $content[2]
 return $body
But It is sending "Java/1.7.0_02" as User-Agent header attribute. This has been taken from wireshark: GET / HTTP/1.1 User-Agent: Java/1.7.0_02 Host: istanbul.olx.com.tr Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive Do we have any way to set the user-agent attribute? Thanks Erol Akarsu
CG
Christian Grünin reply to Erol Akarsu, 1 Nov 2012, 10:331 Nov 2012 09:36 #
Once again, just have a look at the official page and search for the first occurrence of POST: http://www.expath.org/modules/http-client/samples
Quoted text · Erol Akarsu · 55 lines
On Thu, Nov 1, 2012 at 9:33 AM, Erol Akarsu <eakarsu at gmail.com> wrote: > Christian, > > That is what I wanted and it worked! > > I have another thing I need. I need to post a document to a http service > that expects a xml document. To do this, I need to attach an xml document > with http post request > Do we have an example in basex:rrequest to make an http post with > attachment? > > Thanks > > Erol Akarsu > > > > On Wed, Oct 31, 2012 at 6:25 PM, Christian Grün <cg at basex.org> wrote: >> >> This may work: >> >> <http:header name="User-Agent" value="blub"/> >> >> The spec may give you some more hints [1]. >> Christian >> >> [1] http://www.expath.org/spec/http-client >> >> >> > I am trying to set User-Agent header attribute for an HTTP request with >> > following code snippet. >> > >> > >> > let $content := http:send-request(<http:request method='get' >> > status-only='false' User-Agent='Mozilla/5.0'/>, $url) >> > let $body := $content[2] >> > return $body >> > >> > But It is sending "Java/1.7.0_02" as User-Agent header attribute. This >> > has >> > been taken from wireshark: >> > >> > GET / HTTP/1.1 >> > User-Agent: Java/1.7.0_02 >> > Host: istanbul.olx.com.tr >> > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 >> > Connection: keep-alive >> > >> > Do we have any way to set the user-agent attribute? >> > >> > Thanks >> > >> > Erol Akarsu > >
EA
Erol Akarsuin reply to Christian Grün, 31 Oct 2012, 23:251 Nov 2012 10:33 #
Christian, That is what I wanted and it worked! I have another thing I need. I need to post a document to a http service that expects a xml document. To do this, I need to attach an xml document with http post request Do we have an example in basex:rrequest to make an http post with attachment? Thanks Erol Akarsu
Quoted text · Christian Grün · 36 lines
On Wed, Oct 31, 2012 at 6:25 PM, Christian Grün <cg at basex.org> wrote: > This may work: > > <http:header name="User-Agent" value="blub"/> > > The spec may give you some more hints [1]. > Christian > > [1] http://www.expath.org/spec/http-client > > > > I am trying to set User-Agent header attribute for an HTTP request with > > following code snippet. > > > > > > let $content := http:send-request(<http:request method='get' > > status-only='false' User-Agent='Mozilla/5.0'/>, $url) > > let $body := $content[2] > > return $body > > > > But It is sending "Java/1.7.0_02" as User-Agent header attribute. This > has > > been taken from wireshark: > > > > GET / HTTP/1.1 > > User-Agent: Java/1.7.0_02 > > Host: istanbul.olx.com.tr > > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 > > Connection: keep-alive > > > > Do we have any way to set the user-agent attribute? > > > > Thanks > > > > Erol Akarsu >

⚡Generated with XQuery